#ifndef __STREAM_PARSE_H_
#define __STREAM_PARSE_H_

#include <stdint.h>

/* return error*/
#define PARSE_DONE       0
#define PARSE_OVERTIME  -1
#define PARSE_FAIL      -2
#define PARSE_ING       -3

struct essential_keyword
{
    uint8_t *str;
    uint32_t len;
};

typedef struct essential_keyword ParseRef;

struct optional_cmd
{
    uint8_t *at;
    uint32_t len;
    uint8_t *param;
    uint32_t param_len;
};
typedef struct optional_cmd ParseOptCmd;

struct result_buf
{
    uint8_t *buf;
    uint32_t len;
};
typedef struct result_buf ParseRes;

struct parse_obj
{
    ParseRef ref;
    ParseRes res;
    ParseOptCmd cmd;
};
typedef struct parse_obj ParseObj;

extern int8_t streamParseRuntime(void);
extern int8_t parseRefFromStream(ParseObj *obj,uint32_t overtime_ms);
extern int32_t getTcpDataFromStream(uint8_t channel,uint8_t *buf,uint32_t len);

#endif
